package com.czkt.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.czkt.shop.pojo.GoodsCategory;
import com.czkt.shop.mapper.GoodsCategoryMapper;
import com.czkt.shop.service.IGoodsCategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author baomidou
 * @since 2024-09-04
 */
@Service
public class GoodsCategoryServiceImpl extends ServiceImpl<GoodsCategoryMapper, GoodsCategory> implements IGoodsCategoryService {

    @Override
    public List<GoodsCategory> list(Integer pid) {

        LambdaQueryWrapper<GoodsCategory> queryWrapper = new LambdaQueryWrapper<>();

        queryWrapper.eq(pid != null,GoodsCategory::getParentId,pid);

        return baseMapper.selectList(queryWrapper);

    }

    @Override
    public List<GoodsCategory> list(Set<Integer> set) {

        LambdaQueryWrapper<GoodsCategory> queryWrapper = new LambdaQueryWrapper<>();

        queryWrapper.in(!set.isEmpty(),GoodsCategory::getParentId,set);

        return baseMapper.selectList(queryWrapper);

    }
}
